package xyz.luhui1hao.sell.converter;

import org.springframework.beans.BeanUtils;
import xyz.luhui1hao.sell.domain.OrderMaster;
import xyz.luhui1hao.sell.dto.OrderDTO;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName OrderMaster2OrderDTOConverter
 * @Description TODO
 * @Author luhui1hao
 * @Date 2018/8/27 下午4:57
 * @Version 1.0
 */
public class OrderMaster2OrderDTOConverter {

    /**
     * 将OrderMaster转化为OrderDTO
     * @param orderMaster
     * @return
     */
    public static OrderDTO convert(OrderMaster orderMaster){
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(orderMaster, orderDTO);

        return orderDTO;
    }

    /**
     * 将OrderMaster集合转化为OrderDTO集合
     * @param orderMasterList
     * @return
     */
    public static List<OrderDTO> convert(List<OrderMaster> orderMasterList){
        List<OrderDTO> orderDTOList = new ArrayList<>();

        for (OrderMaster orderMaster: orderMasterList) {
            orderDTOList.add(convert(orderMaster));
        }

        return orderDTOList;
    }
}
